(require-extension test)
(import test)

(test-begin "Section 1.1")

(load "ex1.3.scm")

(test 4 (square 2))
(test 25 (square 5))

(test 25 (sum-of-squares  3 4))

(test 1 (min 1 2))
(test -1 (max -1 -2))

(test 13 (sum-squares-2-biggest 1 2 3))
(test 13 (sum-squares-2-biggest 2 3 -4))
(test 13 (sum-squares-2-biggest 3 1 2))

;; todo: write tests for these; need to figure out how to test
;; with floating point numbers
(load "ex1.7.scm")
(load "ex1.8.scm")

(test-end "Section 1.1")

(test-begin "Section 1.2")

(load "ex1.11.scm")

(test 0 (f-r 0))
(test 1 (f-r 1))
(test 2 (f-r 2))
(test 4 (f-r 3))
(test 11 (f-r 4))
(test 25 (f-r 5))

(test 0 (f-i 0))
(test 1 (f-i 1))
(test 2 (f-i 2))
(test 4 (f-i 3))
(test 11 (f-i 4))
(test 25 (f-i 5))

(load "ex1.12.scm")

(test 1 (pascal-triangle 1 1))
(test 1 (pascal-triangle 10 10))
(test 1 (pascal-triangle 10 1))
(test 2 (pascal-triangle 3 2))
(test 3 (pascal-triangle 4 2))
(test 6 (pascal-triangle 5 3))

(load "ex1.16.scm")

(test 1 (expt 3 0))
(test 3 (expt 3 1))
(test 16 (expt 2 4))
(test 32 (expt 2 5))
(test 14348907 (expt 3 15))

(load "ex1.17.scm")
(test 0 (mul 0 100))
(test 0 (mul 100 0))
(test 100 (mul 100 1))
(test 100 (mul 1 100))
(test 56 (mul 7 8))
(test (- 56) (mul -7 8))
(test (- 56) (mul 7 -8))

(load "ex1.18.scm")
(test 0 (mul-i 0 100))
(test 0 (mul-i 100 0))
(test 100 (mul-i 100 1))
(test 100 (mul-i 1 100))
(test 56 (mul-i 7 8))
(test (- 56) (mul-i -7 8))
(test (- 56) (mul-i 7 -8))

(load "ex1.19.scm")
(test 0 (fib 0))
(test 1 (fib 1))
(test 1 (fib 2))
(test 2 (fib 3))
(test 3 (fib 4))
(test 5 (fib 5))
(test 8 (fib 6))

(test-end "Section 1.2")